package com.example.wsh.worddemo.Notebook_Fragment;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

import com.example.wsh.worddemo.DatabaseFile.AssetsDatabaseManager;
import com.example.wsh.worddemo.DatabaseFile.CursorGetAll;
import com.example.wsh.worddemo.Notebook_Fragment.Notebook_Adapter;
import com.example.wsh.worddemo.R;

public class NotebookFragment extends Fragment {

    private ListView view_test;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.notebook_fragment,container,false);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        Cursor cursor = CursorGetAll.execute();
        Notebook_Adapter cursorAdapter = new Notebook_Adapter(getActivity(),R.layout.item,cursor, new String[]{"name"},new int[]{R.id.name},SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
        try{
            view_test = getActivity().findViewById(R.id.view_test);
        }catch (Exception e){
            Log.d("WSHH",e.toString());
        }
        try {
            view_test.setAdapter(cursorAdapter);
        }catch (Exception e){
            Log.d("WSHH",e.toString());
        }
    }


}

